package com.yf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.yf.entity.CmsCategory;
import com.yf.entity.CmsContent;
import com.yf.service.ArticleService;
import com.yf.service.CategoryService;


@Controller
@RequestMapping("/article")
public class ArticleController {
	
	@Autowired
	private CategoryService categoryService;
	@Autowired
	private ArticleService articleService;
	
	/**
	 * 文章详情
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/detail/{id}")
	private ModelAndView ArticlDetail(@PathVariable Long id) {
		ModelAndView mv=new ModelAndView();
		CmsContent content=articleService.getArticleById(id);
		CmsCategory department=categoryService.getCategoryById(content.getCategoryId());
		mv.addObject("department", department);
		mv.addObject("content", content);
		mv.setViewName("article-detail");
		return mv;
	}
}
